package flow.service;

import com.alibaba.fastjson.JSONObject;
import flow.model.FlowBusiness;
import flow.model.FlowInstance;
import flow.model.FlowInstanceSection;
import flow.model.FlowSectionLink;
import m.appserver.ActionRedirect;
import manage.model.AdminLogin;
import manage.model.OrgGroupView;

import java.util.List;

public interface IFlowService {
	/**
	 * 获取该服务类对应的流程标识
	 * 可根据busiParam返回不同类型的流程标识
	 */
	String getFlowIdentity(String busiParam);
	/**
	 * 根据section和business返回下一步可操作环节
	 * 无需判断请直接 return links;
	 */
	List<FlowSectionLink> nextSectionLink(List<FlowSectionLink> links, FlowInstanceSection section, FlowBusiness business);
	/**
	 * 返回业务内容
	 * business 流程业务
	 * adminOid 当前登陆人oid
	 */
	ActionRedirect getRedirectPage(FlowBusiness business, AdminLogin admin, OrgGroupView org, boolean edit) throws Exception;
	/**
	 * 处理流程后执行
	 *  param 参数  可根据参数判断，修改业务类属性
	 *  ins 流程实例  可根据流程实例的当前环节标识，修改业务属性
	 *  nextInsSec 流程实例环节  可查看下一步执行人
	 *  Exception 抛异常回滚流程
	 */
	void processFlowAfter(String param, FlowInstance ins, List<FlowInstanceSection> nextInsSec, JSONObject flowModel) throws Exception;

	/**
	 * 暂存流程后执行
	 * 如果业务表主键为空，请使用ins.getBusiness().getOid()作为oid
	 */
	void saveFlowAfter(FlowInstance ins, List<FlowInstanceSection> nextInsSec, JSONObject flowModel) throws Exception;
	/**
	 * 转发流程后执行
	 *  ins 流程实例  可根据流程实例的当前环节标识，修改业务属性
	 *  nextInsSec 流程实例环节  可查看下一步执行人
	 *  Exception 抛异常回滚流程
	 */
	void forwardFlowAfter(FlowInstance ins, List<FlowInstanceSection> nextInsSec) throws Exception;
}
